<!-- components/Dialog/Dialog.vue -->
<template>
  <div v-if="visible" class="dialog-overlay">
    <div class="dialog-container" @click.stop>
      <div v-if="title" class="dialog-header">
        {{ title }}
      </div>
      <div class="dialog-body">
        {{ content }}
      </div>
      <div class="dialog-footer">
        <button class="dialog-btn cancel" @click="cancel">{{ cancelText }}</button>
        <button class="dialog-btn confirm" @click="confirm">{{ confirmText }}</button>
      </div>
    </div>
  </div>
</template>

<script setup>
const props = defineProps({
  title: {
    type: String,
    default: ''
  },
  content: {
    type: String,
    default: ''
  },
  visible: {
    type: Boolean,
    default: false
  },
  cancelText: {
    type: String,
    default: '取消'
  },
  confirmText: {
    type: String,
    default: '确定'
  }
})

const emit = defineEmits(['close', 'confirm', 'cancel'])

const handleOverlayClick = () => {
  emit('close')
}

const cancel = () => {
  emit('cancel')
  emit('close')
}

const confirm = () => {
  emit('confirm')
  emit('close')
}
</script>

<style lang="scss" scoped>
.dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  backdrop-filter: blur(2px);
  animation: fadeIn 0.3s ease;
}

.dialog-container {
  width: 280px;
  background: #1a1a2e;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  border: 1px solid #2d2d44;
  transform: scale(0.95);
  animation: popIn 0.3s ease forwards;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes popIn {
  from {
    transform: scale(1.2);
  }

  to {
    transform: scale(1);
  }


}

.dialog-header {
  padding: 10px 20px;
  text-align: center;
  font-size: 16px;
  color: #fff;
  border-bottom: 1px solid #161823;
  font-weight: bold;
}

.dialog-body {
  padding: 15px;
  color: #ccc;
  line-height: 1.5;
  text-align: center;
  font-size: 14px;
  font-weight: bold;
}

.dialog-footer {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 2px solid #161823;
  position: relative;

  &::after {
    content: '';
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: 0;
    width: 2px;
    height: 100%;
    background: #161823;
  }
}

.dialog-btn {
  flex: 1;
  padding: 10px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 500;
}

.dialog-btn.cancel {
  background: #2a2a3c;
  color: #aaa;
  border: 1px solid #3a3a50;
}

.dialog-btn.confirm {
  background: #209ff5;
  color: white;
  border: 1px solid #1b87d8;
}

.dialog-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.dialog-btn:active {
  transform: translateY(0);
}
</style>